/*    */ package com.iris.egrant.orm.hibernate;
/*    */ 
/*    */ import com.iris.egrant.utils.ReflectionUtils;
/*    */ import java.io.Serializable;
/*    */ import java.lang.annotation.Annotation;
/*    */ import java.lang.reflect.Field;
/*    */ import java.lang.reflect.Method;
/*    */ import org.hibernate.HibernateException;
/*    */ import org.hibernate.engine.SessionImplementor;
/*    */ import org.hibernate.id.Configurable;
/*    */ import org.hibernate.id.PersistentIdentifierGenerator;
/*    */ import org.hibernate.id.SequenceGenerator;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AssignedSequenceGenerator
/*    */   extends SequenceGenerator
/*    */   implements PersistentIdentifierGenerator, Configurable
/*    */ {
/*    */   public Serializable generate(SessionImplementor session, Object obj) throws HibernateException {
/* 33 */     Method[] methods = obj.getClass().getDeclaredMethods();
/* 34 */     for (Method method : methods) {
/* 35 */       Annotation[] annotations = method.getAnnotations();
/* 36 */       for (Annotation annotation : annotations) {
/*    */         
/* 38 */         if (annotation instanceof javax.persistence.Id) {
/* 39 */           Serializable id = (Serializable)ReflectionUtils.invokeMethod(obj, method.getName(), null, null);
/*    */           
/* 41 */           if (id != null) {
/* 42 */             return id;
/*    */           }
/*    */           
/* 45 */           return super.generate(session, obj);
/*    */         } 
/*    */       } 
/*    */     } 
/*    */ 
/*    */ 
/*    */     
/* 52 */     Field[] fields = obj.getClass().getDeclaredFields();
/* 53 */     for (Field filed : fields) {
/* 54 */       Annotation[] annotations = filed.getAnnotations();
/* 55 */       for (Annotation annotation : annotations) {
/*    */         
/* 57 */         if (annotation instanceof javax.persistence.Id) {
/* 58 */           Serializable id = (Serializable)ReflectionUtils.getFieldValue(obj, filed.getName());
/*    */           
/* 60 */           if (id != null) {
/* 61 */             return id;
/*    */           }
/*    */           
/* 64 */           return super.generate(session, obj);
/*    */         } 
/*    */       } 
/*    */     } 
/*    */ 
/*    */     
/* 70 */     return super.generate(session, obj);
/*    */   }
/*    */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-core-2.2.20240205.1659.jar!\com\iris\egrant\orm\hibernate\AssignedSequenceGenerator.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */